﻿// <copyright file="AxHostConverter.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2010-06-30</date>
// <summary>Converter for System.Drawing.Image to/from IPictureDisp</summary>

namespace WordFlowDocumentCreator
{
    using System.Drawing;
    using System.Windows.Forms;

    /// <summary>
    /// Converter for System.Drawing.Image to/from IPictureDisp
    /// </summary>
    internal class AxHostConverter : AxHost
    {
        /// <summary>
        /// Prevents a default instance of the AxHostConverter class from being created.
        /// </summary>
        private AxHostConverter() : base(string.Empty) 
        { 
        }

        /// <summary>
        /// Convert from an Image object to a IPictureDisp interface
        /// </summary>
        /// <param name="image">an image object</param>
        /// <returns>an IPictureDisp interface</returns>
        public static stdole.IPictureDisp ImageToPictureDisp(Image image)
        {
            return (stdole.IPictureDisp)GetIPictureDispFromPicture(image);
        }

        /// <summary>
        /// Convert from an IPictureDisp interface to an Image object
        /// </summary>
        /// <param name="pictureDisp">an IPictureDisp interface</param>
        /// <returns>an Image object</returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Utility method.")]
        public static Image PictureDispToImage(stdole.IPictureDisp pictureDisp)
        {
            return GetPictureFromIPicture(pictureDisp);
        }
    }
}
